package com.cj.cms.web;

import org.springframework.beans.factory.annotation.Autowired;

import com.cj.cms.entity.Article;
import com.cj.cms.entity.Channel;
import com.cj.cms.entity.WebSite;
import com.cj.cms.service.ArticleManager;
import com.cj.sys.service.security.SysConfigManager;

public class ArticleWebAction extends BaseWebAction{
	@Autowired
	private ArticleManager articleManager;
	private WebSite webSite;
	private String viewFtl;
	private Long id;
	private Article entity;
	public String execute(){
		try {
			entity = articleManager.get(id);
			webSite = entity.getChannel().getWebSite();
			//需要验证的栏目
			if(SysConfigManager.configByType(Channel.NEED_LOGIN).containsKey(entity.getChannel().getCode())){
				if(getIsLogin().intValue() != 1)
					return "no_login";
			}
			viewFtl = entity.getChannel().getContentTemplate().getPath();
			return SUCCESS;
		} catch (Exception e) {
			setErrMessage(e.getMessage(), e);
			return ERROR;
		}
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public WebSite getWebSite() {
		return webSite;
	}
	public String getViewFtl() {
		return viewFtl;
	}
	public Article getEntity() {
		return entity;
	}

}
